﻿/*文件注释
 * ===============================================================================
 * 说明：
 * 作者：曾永佑
 * 版本：V1.0
 * 创建日期：2013-03-10
 * 完成日期： 
 * 修改纪录：  
 * ===============================================================================
 */  
        
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SRF.Security.Principal;

namespace SRF.Components.Security
{
    public class MyMembershipProvider : MembershipProvider
    {
        readonly Data.DBHelperBase dbhelper = Data.DBHelperFactory.GetDBHelper();

        public override IUser GetUser(string loginId)
        {
            return dbhelper.GetQuery(Constants.GetUserSQL).SetParameter(new { LoginId = loginId }).UniqueResult<User>();
        }
        public override bool VerifyPassword(string loginId, string password)
        {
            return dbhelper.GetQuery(Constants.GetUserVerifyPasswordSQL).SetParameter(new { LoginId = loginId, Password = password }).Exists();
        }

        public override void ChangePassword(string loginId, string newPassword)
        {
            dbhelper.GetQuery(Constants.GetUserChangePasswordSQL).SetParameter(new { loginid = loginId, password = newPassword }).Execute();
        }
    }
}